package Top200;

/**
 * @author zhangmin
 * @create 2022-02-26 15:54
 */
public class merge88 {
    public void merge(int[] nums1, int m, int[] nums2, int n) {
        int i=0,j=0,k=0;
        int[] temp=new int[m+n];
        while (i<m&&j<n){
            if (nums1[i]<=nums2[j]){
                temp[k]=nums1[i];
                i++;
            }else {
                temp[k]=nums2[j];
                j++;
            }
            k++;
        }
        for (; i < m; i++) {
            temp[k++]=nums1[i];
        }
        for (; j < n; j++) {
            temp[k++]=nums2[j];
        }
        for (k = 0; k < m+n; k++) {
            nums1[k]=temp[k];
        }
    }
}
